package com.usian.article.controller;

import com.usian.article.service.ApAuthorService;
import com.usian.model.article.ApAuthor;
import com.usian.model.base.BaseResult;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("api/v1/author")
public class ApAuthorController implements BaseResult {
    @Autowired
    private ApAuthorService service;

    @PostMapping("/save")
    public ResponseResult saveAuthor(@RequestBody ApAuthor author) {
        if (author == null) return paramError;
        service.save(author);
        return success(author.getId());
    }

    @GetMapping("getById/{authorId}")
    public ApAuthor getById(@PathVariable Integer authorId) {
        return service.getById(authorId);
    }
}
